home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_10
/
1010016b
< prev
next >
Wrap
Text File
|
1992-08-11
|
343b
|
18 lines
Listing 5 -- the file strncpy.c
/* strncpy function */
#include <string.h>
char *(strncpy)(char *s1, const char *s2, size_t n)
{ /* copy char s2[max n] to s1[n] */
char *s;
for (s = s1; 0 < n && *s2 != '\0'; --n)
*s++ = *s2++; /* copy at most n chars from s2[] */
for (; 0 < n; --n)
*s++ = '\0';
return (s1);
}